package com.jinmdz.fmis.mapper.mapper;

import com.jinmdz.fmis.mapper.entity.SystemOperationLogEntity;
import com.jinmdz.fmis.mapper.mapper.provider.SystemOperationLogProvider;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

/**
 * 系统操作日志表Mapper
 *
 * @author generator
 * @date 2020-03-12 17:08
 */
public interface SystemOperationLogMapper {

    /**
     * 增加SystemOperationLog
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @InsertProvider(type = SystemOperationLogProvider.class, method = "insertSystemOperationLog")
    @Options(useGeneratedKeys = true, keyProperty = "entity.id", keyColumn = "id")
    void insertSystemOperationLog(@Param("entity") SystemOperationLogEntity entity);

    /**
     * 删除SystemOperationLog
     *
     * @param id             主键
     * @param modifiedUserId 修改用户外键
     * @param version        版本号
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Update(" update system_operation_log set deleted = 1,modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void deletedForSystemOperationLog(@Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);

    /**
     * 修改SystemOperationLog
     *
     * @param entity 数据实体
     * @return
     * @author generator
     * @date 2020-03-12 17:08
     */
    @UpdateProvider(type = SystemOperationLogProvider.class, method = "updateSystemOperationLog")
    void updateSystemOperationLog(@Param("entity") SystemOperationLogEntity entity);

    /**
     * 查询SystemOperationLog实体
     *
     * @param id 主键
     * @return SystemOperationLogEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @Select(" select id,deleted,operation_type_code,operation_type,business_code,business_type_code,business_type,business_describe,log_content,log_describe,log_form,old_value,new_value,remark,create_user_name,funeral_parlour_code,create_user_id,gmt_create,unmodified,modified_user_id,gmt_modified,version from system_operation_log where id = #{id} and deleted = 0 limit 1 ")
    SystemOperationLogEntity getSystemOperationLogById(@Param("id") Integer id);

    /**
     * 查询SystemOperationLog列表
     *
     * @param entity 数据实体
     * @return SystemOperationLogEntity
     * @author generator
     * @date 2020-03-12 17:08
     */
    @SelectProvider(type = SystemOperationLogProvider.class, method = "listSystemOperationLog")
    ArrayList<SystemOperationLogEntity> listSystemOperationLog(@Param("entity") SystemOperationLogEntity entity);
}